﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using VkontakteSharp;
using VkontakteSharp.Enums;
using VkontakteSharp.Model;

namespace VkontakteSharp.Endpoints.Groups {
    public class Authenticated : VkontakteAPI
    {
        public Authenticated(VkontakteConfig config, string authInfo) : base(config, authInfo, "/groups.") { }


        public Response<List<Group>> GetById(string[] clubIds, GroupFields? fields = null)
        {
            return (Response<List<Group>>)Mapper.Map<Response<List<Group>>>(GetByIdJson(clubIds, fields));
        }

        public string GetByIdJson(string[] clubIds, GroupFields? fields = null)
        {
            if (clubIds.Length > 500)
            {
                throw new ArgumentOutOfRangeException("clubIds", "Can't be more than 500");
            }
            string uri = string.Format(base.Uri + "getById?v=3.0&access_token={0}&gids={1}", 
                AuthInfo, String.Join(",", clubIds));
            if(fields.HasValue)
            {
                uri += "&fields=" + (String.Join(",", fields.Value)).Replace(", ", ",");
            }
            return HttpClientOld.GET(uri);
        }

    }
}
